<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::group(['prefix'=>'admin','namespace'=>'Admin'],function(){
    Route::any('login','LoginController@login')->name('admin.login');
    Route::get('code','LoginController@code')->name('admin.code');
});


Route::group(['prefix'=>'admin','namespace'=>'Admin','middleware'=>['admin.login','admin.auth']],function(){
    Route::any('index','IndexController@index')->name('admin.index');
    Route::get('info','IndexController@info')->name('admin.info');
    Route::get('quit','LoginController@quit')->name('admin.quit');
    Route::any('pass','IndexController@pass')->name('admin.pass');
});

//权限管理路由
Route::group(['prefix'=>'admin','namespace'=>'Auth','middleware'=>['admin.login','admin.auth']],function(){
    Route::get('auth','AuthController@index')->name('admin.auth');
    Route::get('user','AuthController@user')->name('admin.user');
    Route::get('group','AuthController@group')->name('admin.group');
    Route::get('role','AuthController@role')->name('admin.role');
    //用户管理
    Route::any('user/createUser','AuthController@createUser')->name('admin.user.userAdd');
    Route::any('user/editUser/{id?}','AuthController@editUser')->where('id', '[0-9]+')->name('admin.user.userEdit');
    Route::post('user/delUser/{id?}','AuthController@delUser')->where('id', '[0-9]+')->name('admin.user.userDel');
    //用户组管理
    Route::any('group/createGroup','AuthController@createGroup')->name('admin.group.groupAdd');
    Route::any('group/editGroup/{id?}','AuthController@editGroup')->where('id', '[0-9]+')->name('admin.group.groupEdit');
    Route::post('group/delGroup/{id?}','AuthController@delGroup')->where('id', '[0-9]+')->name('admin.group.groupDel');
    //权限管理
    Route::any('role/createRole','AuthController@createRole')->name('admin.role.roleAdd');
    Route::any('role/editRole/{id?}','AuthController@editRole')->where('id', '[0-9]+')->name('admin.role.roleEdit');
    Route::post('role/delRole/{id?}','AuthController@delRole')->where('id', '[0-9]+')->name('admin.role.roleDel');
});

//分类处理
Route::group(['prefix'=>'admin','namespace'=>'Admin','middleware'=>['admin.login','admin.auth']],function(){
    Route::resource('category','CategoryController');
    Route::post('category/changeorder','CategoryController@changeOrder')->name('admin.category.changeOrder');
});

//后端错误处理
Route::group(['prefix'=>'admin','namespace'=>'Errors'],function(){
    Route::get('401','ErrorsController@e401');
    Route::get('403','ErrorsController@e403');
    Route::get('404','ErrorsController@e404');
    Route::get('500','ErrorsController@e500');
});
